package com.xckj.teacher.ui.adapter

import android.annotation.SuppressLint
import android.graphics.drawable.Drawable
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.xckj.teacher.R
import com.xckj.teacher.bean.ClassBean
import com.xckj.teacher.bean.Group
import com.xckj.teacher.bean.Student
import com.xckj.teacher.util.CustomBindAdapter


class StudentAdapter(data: MutableList<Student>) : BaseQuickAdapter<Student, BaseViewHolder>(
    R.layout.item_class_student, data
) {


    @SuppressLint("UseCompatLoadingForDrawables")
    override fun convert(holder: BaseViewHolder, item: Student) {
        holder.setText(R.id.tv_name, "${item.nickname}")
        holder.setText(R.id.tv_account, "账号${item.username}")
        if (item.is_vip){
            val drawable: Drawable = context.resources.getDrawable(R.mipmap.vip)
            holder.getView<TextView>(R.id.tv_name).setCompoundDrawablesWithIntrinsicBounds(null, null, drawable, null)
        }

        if (!item.avatar.startsWith("https:")){
            item.avatar="https://d-xueer.bigchun.com/${item.avatar}"
        }
        CustomBindAdapter.circleImageUrl(holder.getView(R.id.iv_stu),item.avatar)
    }
}
